DropdownUtil = {
	create : function(id) {
		var type = "dropdown";
		var uid = Math.uuid();
		
		var c = null;
		if (Util.isNotEmpty(id)) {
			c = Vari.fieldMap.get(id);
		}
		
		var f = (Vari.tpl.filterProperty('type', type)[0]);
		var n = App.FieldVo.create(f);

		Ember.mixin(n, {
			uid: uid
		});
				
		n.get("options").forEach(function(optVo) {
			Ember.mixin(optVo, {
				uid: Math.uuid(),
				group: uid
			});
		});
		
		if (Util.isNotEmpty(c)) {			
			var pos = Vari.frm.get("fields").indexOf(c) + 1;
			Vari.frm.get("fields").insertAt(pos, n);
		} else {
			Vari.frm.get("fields").pushObject(n);
		}	
		Vari.fieldMap.set(uid, n);	
		DropdownUtil.show(n);
	},

	show : function(fieldContext) {
		var choiceView = App.DropdownEditView.create();
		var containerView = Em.View.views['form_canvas_view'];
		containerView.get('childViews').pushObject(choiceView);

		choiceView.set("context", fieldContext);
		
		containerView.get('childViews').sort(function(a,b) {
			return a.get("context").get("indexx") - b.get("context").get("indexx");			
		});
	},

};